<?php

function spiel_entfernen ($match)
{
	include("inc_configuration.php");
	
	$ret="";
	
	$q="DELETE FROM $tbl_matches WHERE id=$match";
	$qe=mysql_query($q);
	
	$ret.="$q    --    ";
	
	$q="DELETE FROM $tbl_comments WHERE matchId=$match";
	$qe=mysql_query($q);
	
	$ret.="$q    --    ";
	
	$q="DELETE FROM $tbl_bestaetigung WHERE matchId=$match";
	$qe=mysql_query($q);
	
	$ret.="$q    --    ";
	
	$q="DELETE FROM $tbl_events WHERE matchId=$match";
	$qe=mysql_query($q);
	
	$ret.="$q    --    ";
	
	$q="DELETE FROM $tbl_forderungen WHERE matchId=$match";
	$qe=mysql_query($q);
	
	$ret.="$q";
	
	return $ret;
}

function spiele_entfernen_liga ($liga)
{
	include("inc_configuration.php");
	
	$ret="";
	
	$q="SELECT id FROM $tbl_matches WHERE leagueId=$liga";
	$qe=mysql_query($q);
	
	$ret.="$q    --    ";
	
	while ($row=mysql_fetch_object($qe))
	{
		$match=$row->id;
		$del=spiel_entfernen($match);
		
		$ret.="/--/--/ $del /--/--/";
	}
	
	return $ret;
}

function spiele_entfernen_gruppe ($gruppe)
{
	include("inc_configuration.php");
	
	$q="SELECT id FROM $tbl_matches WHERE stageId=$gruppe";
	$qe=mysql_query($q);
	
	while ($row=mysql_fetch_object($qe))
	{
		$match=$row->id;
		$del=spiel_entfernen($match);
	}
	
	return true;
}

function gruppe_entfernen ($gruppe)
{
	include("inc_configuration.php");
	
	$q="DELETE FROM $tbl_lg WHERE id=$gruppe";
	$qe=mysql_query($q);
	
	$q="DELETE FROM $tbl_gt WHERE groupId=$gruppe";
	$qe=mysql_query($q);
	
	$del=spiele_entfernen_gruppe($gruppe);
	
	return true;
}

function liga_entfernen ($liga)
{
	include("inc_configuration.php");
	
	$q="DELETE FROM $tbl_leagues WHERE id=$liga";
	$qe=mysql_query($q);
	
	$q="DELETE FROM $tbl_lt WHERE leagueId=$liga";
	$qe=mysql_query($q);
	
	$q="DELETE FROM $tbl_rankings WHERE leagueId=$liga";
	$qe=mysql_query($q);
	
	$q="SELECT id FROM $tbl_lg WHERE leagueId=$liga";
	$qe=mysql_query($q);
	
	while ($row=mysql_fetch_object($qe))
	{
		$gruppe=$row->id;
		$del=gruppe_entfernen($gruppe);
	}
	
	$del=spiele_entfernen_liga($liga);
}


function saison_entfernen ($saison)
{
	include("inc_configuration.php");
	
	$q="DELETE FROM $tbl_season WHERE id=$saison";
	$qe=mysql_query($q);
	
	$q="DELETE FROM $tbl_trainerwechsel WHERE seasonId=$saison";
	$qe=mysql_query($q);
	
	$q="SELECT id FROM $tbl_leagues WHERE seasonId=$saison";
	$qe=mysql_query($q);
	
	while ($row=mysql_fetch_object($qe))
	{
		$liga=$row->id;
		$del=liga_entfernen($liga);
	}
	
	return true;
}



?>